package org.wmine.algo;

import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.Vector;


import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
public class clusteringLast extends JFrame
{
	private static final int CENTER = 0;
	private static final int RIGHT = 0;
	int i;String classLbl;
	final JCheckBox [] cb111;
	int [] checkCnt;
	int [] selected;
	
	String[]attribs1;
	int colknt1,cntRow1;String Goalitem;
	String[][]data2;
	public clusteringLast(final String[]attribs,final int colknt,final int cntRow,final String [][] data)
	{
		attribs1=attribs;
		colknt1=colknt;
		cntRow1=cntRow;
		data2=data;
		final Container c=this.getContentPane();
		this.setTitle("Select the Attributes");
	
		JPanel mainPanel=new JPanel();
		mainPanel.setLayout(new GridLayout(colknt+3,1));
		mainPanel.add(new JLabel("Select the attributes to be considered:"));
		cb111=new JCheckBox[colknt];
		checkCnt=new int[colknt];
				ActionListener listener=new ActionListener(){public void actionPerformed(ActionEvent ae){update();}};
		for(i = 0;i<colknt;i++)
		{
			cb111[i]=new JCheckBox(attribs[i]);
			cb111[i].addActionListener(listener);
			mainPanel.add(cb111[i]);
		}
		selected=new int[cb111.length];
		mainPanel.add(new JLabel(""));
		JButton but1=new JButton("OK");
		but1.setBounds(10,45,110,20);
		mainPanel.add(but1);
		but1.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent ae)
		{
			dispose();
			
			for(int s=0;s<cb111.length;s++)
				get(s);
			clustering sd=new clustering(attribs1,colknt1,cntRow1,data2,selected);
			sd.setBounds(350,300,310,180);
			sd.setVisible(true);
		}});
		c.add(mainPanel);
		this.setBounds(300,200,300,(30*(colknt+1)));
	
	}
	
	void update()	{}
	void get(int i)
	{
		if(cb111[i].isSelected())
		{
			System.out.print("ok");
			selected[i]=1;
		}
		else
		selected[i]=0;
	}
	public static void main(String [] args)
	{}
}

